<?php
$div_content = '';

/*
 * Shared modules are loaded, replace every {MODULE_FOO} by the module_foo.thtml element
 */
// TODO str_replace on an array could use less CPU cycles
              
// code needed for the animation
$div_content .= View::element('slideanim');
if (preg_match_all('#{MODULE_(.*?)}#s', $feed['Feed']['template'], $m)) {
    for ($i=0; isset($m[1][$i]); $i++) {
	        $feed['Feed']['template'] = 
	            str_replace($m[0][$i],
	                        View::element('module_'.strtolower($m[1][$i])), 
	                        $feed['Feed']['template']);
	    }
}


$div_content .= 
'<div id="slide">
'.$this->Html->scriptBlock(
    "pageTransition('".$this->webroot."/slides/slideshow/".$feed['Feed']['id']."/1', 
				'1000');").'<br/><br/>'.'
<h1>'.$this->Js->link($feed['Feed']['name'],
                  '/slides/slideshow/'.$feed['Feed']['id'].'/1', 
                  array('update' => 'slide')).'</h1>
<p>'.$feed['Feed']['description'].'</p>
</div>';
$div_content .= $this->Html->scriptBlock("");
    
                  
// prints the whole content on the screen
echo str_replace( '<div id="slide"></div>', $div_content , $feed['Feed']['template']);

